<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('purchase_user_id')->comment('下单人id');
            $table->unsignedBigInteger('price')->default(0)->comment('订单价格');
            $table->string('number')->unique()->comment('订单编号');
            $table->unsignedBigInteger('purchaser_address_id')->comment('收货地址id');
            $table->unsignedTinyInteger('status')->default(0)->comment('订单状态 0 待付款 1 待发货 2 待收货 3 已完成 4 申请退货 5 已退货 6 取消');
            $table->unsignedTinyInteger('payment_type')->default(1)->comment('支付类型 1 线下支付 2 支付宝 3 微信 4 银行卡');
            $table->dateTime('paid_at')->nullable()->comment('支付时间');
            $table->dateTime('shipped_at')->nullable()->comment('发货时间');
            $table->dateTime('finished_at')->nullable()->comment('完成时间');
            $table->dateTime('applied_refund_at')->nullable()->comment('申请退款时间');
            $table->dateTime('canceled_at')->nullable()->comment('取消时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('orders');
    }
};
